USE GESTION2
go

IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO') IS NOT NULL 
   BEGIN
      DROP PROCEDURE dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO 
      IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO') 
      IS
      NOT NULL 
         PRINT 
         '<<< FAILED DROPPING PROCEDURE dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO >>>'
      ELSE
         PRINT 
         '<<< DROPPED PROCEDURE dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO >>>' 
   END
go

SET ANSI_NULLS ON
go

SET QUOTED_IDENTIFIER ON
go

CREATE PROCEDURE [dbo].[WASP_D0004_CREA_TABLA_NUMERO_TELEFONO] 
AS
   BEGIN
      SELECT ctnro,
         MAX (dotelf) tel1,
         MIN (dotelf) tel2
      INTO dbo.NumeroTelefono 
      FROM FSR006 (nolock) 
      GROUP BY ctnro 
   END
go



SET ANSI_NULLS OFF
go

SET QUOTED_IDENTIFIER OFF
go

IF OBJECT_ID('dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO') IS NOT NULL 
   PRINT '<<< CREATED PROCEDURE dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO >>>' 
ELSE
   PRINT 
   '<<< FAILED CREATING PROCEDURE dbo.WASP_D0004_CREA_TABLA_NUMERO_TELEFONO >>>'
go
